package org.elanfox.intellicommunity.biz.dto.msg;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.elanfox.intellicommunity.biz.entity.msg.AlarmMsgPO;
import org.elanfox.intellicommunity.common.ienum.MsgEnums;

/**
 * @author allan
 * @version 1.0.0
 * @date 2019/12/19
 */
@Data
@NoArgsConstructor
public class AlarmMsgDTO extends MsgBaseDTO {
    private static final long serialVersionUID = 364688680724206211L;

    private int alarmStatus;
    private Long groupId;
    private int alarmType;
    private String alarmTypeDesc;
    /**
     * 警报内容模板
     */
    private String alarmTemplate;

    public void setAlarmType(MsgEnums.AlarmType alarmType) {
        this.alarmType = alarmType.getCode();
        this.alarmTypeDesc = alarmType.getDesc();
    }

    public AlarmMsgDTO(AlarmMsgPO alarmMsgPO) {
        super(alarmMsgPO);
        this.alarmStatus = alarmMsgPO.getAlarmMsgGroupPO().getAlarmStatus().getCode();
        this.groupId = alarmMsgPO.getAlarmMsgGroupPO().getGroupId();
    }

    @JsonIgnore
    public boolean isGroup() {
        return this.alarmStatus < MsgEnums.AlarmStatus.HANDLED.getCode();
    }
}
